#include "Bsp_uart.h"

// TODO:添加调试串口
// clang-format off
USR_GPIO_Init Debug_Uart_pin[]={
// UART0     PORT  pin             mode                outputType             pull       remapPin   analogSwitch 
[Uart_Rx] = {GPIOD,{FL_GPIO_PIN_7,FL_GPIO_MODE_DIGITAL,FL_GPIO_OUTPUT_PUSHPULL,FL_DISABLE,FL_ENABLE, FL_DISABLE}},
[Uart_Tx] = {GPIOD,{FL_GPIO_PIN_8,FL_GPIO_MODE_DIGITAL,FL_GPIO_OUTPUT_PUSHPULL,FL_DISABLE,FL_ENABLE, FL_DISABLE}},
};
// clang-format on

// TODO:不建议使用SWD串口复用，会影响RTT和下载。
void usr_uart_Init(void)
{
    FL_UART_InitTypeDef UART_InitStruct;

    uint8_t i = 0;
    // 控制引脚初始化
    for (i = 0; i < (sizeof(Debug_Uart_pin) / sizeof(USR_GPIO_Init)); i++) {
        FL_GPIO_Init(Debug_Uart_pin[i].GPIOx, &Debug_Uart_pin[i].init_type);
    }

    UART_InitStruct.clockSrc          = NULL;
    UART_InitStruct.baudRate          = 115200;
    UART_InitStruct.transferDirection = FL_UART_DIRECTION_TX_RX;
    UART_InitStruct.dataWidth         = FL_UART_DATA_WIDTH_8B;
    UART_InitStruct.stopBits          = FL_UART_STOP_BIT_WIDTH_1B;
    UART_InitStruct.parity            = FL_UART_PARITY_EVEN;

    FL_UART_Init(UART3, &UART_InitStruct);

    // 中断初始化
}
